package tech.eyao.hs60x.worker;

import java.io.File;
import java.io.FileOutputStream;

import tech.eyao.hs60x.common.CommonConstants;

public class UserAvatarWorker extends AbstractImageWorker {
	private String path;
	
	private byte[] file;
	
	private String fileName;

	public UserAvatarWorker(String path,String fileName, byte[] file) {
		this.path = path;
		this.file = file;
		this.fileName = fileName;
	}

	@Override
	public void doRun() {
		File targetFile = new File(path);
		if (!targetFile.exists()) {
			targetFile.mkdirs();
		}
		FileOutputStream out;
		try {
			out = new FileOutputStream(path + fileName);
			out.write(file);
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
